NFLAGS=-f elf
CFLAGS=-c -m32 -ansi -w -I includes -Wall -Wextra -Werror -nostdlib -nostartfiles -nodefaultlibs -fno-builtin
LFLAGS=-m elf_i386 -T linker.ld 

def:
	nasm ${NFLAGS} -o boot/loader.o boot/loader.s
	gcc  ${CFLAGS} -o build/kernel.o kernel.c 
	gcc  ${CFLAGS} -o includes/interrupt.o includes/interrupts.c 
	gcc  ${CFLAGS} -o lib/screen_out.o lib/screen_out.c
	gcc  ${CFLAGS} -o lib/mem.o lib/mem.c 
	gcc  ${CFLAGS} -o lib/mm.o lib/mm.c 
	ld ${LFLAGS} -o build/kernel.bin includes/interrupt.o boot/loader.o build/kernel.o lib/*.o
	dd if=/dev/zero of=boot/pad bs=1 count=750
	cat  boot/stage1 boot/stage2 boot/pad build/kernel.bin > build/boot.img

clean:
	rm -f boot/*.o
	rm -f boot/pad
	rm -f build/*
	rm -f lib/*.o

run:
	qemu -fda build/boot.img -m 512
